package com.thread.threadfirst.javaBase.AnnotationSample;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Configuration、@Component区别 如果AnnotationSample类的注解是@Configuration 输出同一个car，如果是@Component 输出不同的car.
 * 可以理解为@Configuration注解是单例模式 而@Component是使用一次实例化一次。
 * 详情看test类。
 */
@Component
//@Configuration
public class AnnotationSample {
    @Bean
    public Driver driver() {
        Driver driver = new Driver();
        driver.setId(1);
        driver.setName("driver");
        driver.setCar(car());
        return driver;
    }

    @Bean
    public Car car() {
        Car car = new Car();
        car.setId(1);
        car.setName("car");
        return car;
    }
}

